package com.two.screen.water.balance.bean.database;

import com.chad.library.adapter.base.entity.MultiItemEntity;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;

import java.util.List;

import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.DaoException;

@Entity
public class OrderDB implements MultiItemEntity {
    @Id(autoincrement = true)
    public Long   id;//本地订单id
    public String orderSn;//订单编号
    public String totalPrice;//总共需要收款 = sum(线上商品卖的价*数量)
    public String realPrice;//真实收款 = 直接修改后的总价。 总额 - 找零
    public String findZero; //找零
    public int    discountPercent = 100;
    public String giftPrice;//优惠金额 = sum(线上商品卖的优惠价*数量)
    public String totalGiftPrice;//商品总优惠金额 = sum(商品gift)
    public String totalWeight;//数量、重量

    public String payType;//支付类型： //0现金   1微会员    2聚合支付  3会员卡 4扫码
    public String payTypeName;//支付类型：01现金支付、02微会员支付、03聚合码支付
    public String vipCode;//会员卡号
    public String deviceSn;//设备码
    public Long   payTime;//交易时间 时间戳
    public String payTimeName;//交易时间 转化格式显示
    public Long   createTime;//订单创建时间 时间戳
    public String createTimeName;//订单创建时间 转化格式显示
    public String userName;//操作人
    //public String userName1;//操作人 ,这个无意中写多了。有机会删除掉。
    public String userId;//操作人id
    public String token;//预留字段
    public String cardHex;//卡号
    public int    orderType;//订单类型：0正常订单;1挂单;
    public int    orderStatus;//0未支付;1支付中;2已支付;3退货;4:反结账;5：取消支付；

    public Long    uploadFailedTimes = 0L;//上传失败次数
    public int     uploadStatus      = 0;//上传状态。//0:未上传，1:上传成功,2:上传失败
    public String  integralUrl;//积分二维码
    public Boolean isSelected        = false;//本地使用
    public int     item_type         = 0;//本地使用

//    //用到了这个Convert注解，表明它们的转换类，这样就可以转换成String保存到数据库中了
//    @Convert(columnType = String.class, converter = ProductBean2OrderDBConverter.class)
//    public List<ProductBean> goodsList; //实体类中list数据

    // 1对多（后面根据需求再实现另一个product表），@JoinEntity注解：entity 中间表；sourceProperty 实体属性；targetProperty 外链实体属性
//    @ToMany
//    @JoinEntity(
//            entity = JoinOrder2OrderProduct.class,
//            sourceProperty = "oid",
//            targetProperty = "pid"
//    )
    @ToMany(referencedJoinProperty = "orderId")
    private           List<OrderProductDB> orderProductDBList;
    /**
     * Used to resolve relations
     */
    @Generated(hash = 2040040024)
    private transient DaoSession           daoSession;
    /**
     * Used for active entity operations.
     */
    @Generated(hash = 985920434)
    private transient OrderDBDao           myDao;

    @Generated(hash = 1027455337)
    public OrderDB(Long id, String orderSn, String totalPrice, String realPrice, String findZero, int discountPercent,
            String giftPrice, String totalGiftPrice, String totalWeight, String payType, String payTypeName, String vipCode,
            String deviceSn, Long payTime, String payTimeName, Long createTime, String createTimeName, String userName,
            String userId, String token, String cardHex, int orderType, int orderStatus, Long uploadFailedTimes,
            int uploadStatus, String integralUrl, Boolean isSelected, int item_type) {
        this.id = id;
        this.orderSn = orderSn;
        this.totalPrice = totalPrice;
        this.realPrice = realPrice;
        this.findZero = findZero;
        this.discountPercent = discountPercent;
        this.giftPrice = giftPrice;
        this.totalGiftPrice = totalGiftPrice;
        this.totalWeight = totalWeight;
        this.payType = payType;
        this.payTypeName = payTypeName;
        this.vipCode = vipCode;
        this.deviceSn = deviceSn;
        this.payTime = payTime;
        this.payTimeName = payTimeName;
        this.createTime = createTime;
        this.createTimeName = createTimeName;
        this.userName = userName;
        this.userId = userId;
        this.token = token;
        this.cardHex = cardHex;
        this.orderType = orderType;
        this.orderStatus = orderStatus;
        this.uploadFailedTimes = uploadFailedTimes;
        this.uploadStatus = uploadStatus;
        this.integralUrl = integralUrl;
        this.isSelected = isSelected;
        this.item_type = item_type;
    }

    @Generated(hash = 1609986019)
    public OrderDB() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderSn() {
        return this.orderSn;
    }

    public void setOrderSn(String orderSn) {
        this.orderSn = orderSn;
    }

    public String getTotalPrice() {
        return this.totalPrice;
    }

    public void setTotalPrice(String totalPrice) {
        this.totalPrice = totalPrice;
    }

    public String getRealPrice() {
        return this.realPrice;
    }

    public void setRealPrice(String realPrice) {
        this.realPrice = realPrice;
    }

    public String getGiftPrice() {
        return this.giftPrice;
    }

    public void setGiftPrice(String giftPrice) {
        this.giftPrice = giftPrice;
    }

    public String getTotalWeight() {
        return this.totalWeight;
    }

    public void setTotalWeight(String totalWeight) {
        this.totalWeight = totalWeight;
    }

    public String getPayType() {
        return this.payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    public String getPayTypeName() {
        return this.payTypeName;
    }

    public void setPayTypeName(String payTypeName) {
        this.payTypeName = payTypeName;
    }

    public String getVipCode() {
        return this.vipCode;
    }

    public void setVipCode(String vipCode) {
        this.vipCode = vipCode;
    }

    public String getDeviceSn() {
        return this.deviceSn;
    }

    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }

    public Long getPayTime() {
        return this.payTime;
    }

    public void setPayTime(Long payTime) {
        this.payTime = payTime;
    }

    public String getPayTimeName() {
        return this.payTimeName;
    }

    public void setPayTimeName(String payTimeName) {
        this.payTimeName = payTimeName;
    }

    public Long getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getCreateTimeName() {
        return this.createTimeName;
    }

    public void setCreateTimeName(String createTimeName) {
        this.createTimeName = createTimeName;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getToken() {
        return this.token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getCardHex() {
        return this.cardHex;
    }

    public void setCardHex(String cardHex) {
        this.cardHex = cardHex;
    }

    public int getOrderType() {
        return this.orderType;
    }

    public void setOrderType(int orderType) {
        this.orderType = orderType;
    }

    public int getOrderStatus() {
        return this.orderStatus;
    }

    public void setOrderStatus(int orderStatus) {
        this.orderStatus = orderStatus;
    }

    public Long getUploadFailedTimes() {
        return this.uploadFailedTimes;
    }

    public void setUploadFailedTimes(Long uploadFailedTimes) {
        this.uploadFailedTimes = uploadFailedTimes;
    }

    public int getUploadStatus() {
        return this.uploadStatus;
    }

    public void setUploadStatus(int uploadStatus) {
        this.uploadStatus = uploadStatus;
    }

    public String getIntegralUrl() {
        return this.integralUrl;
    }

    public void setIntegralUrl(String integralUrl) {
        this.integralUrl = integralUrl;
    }

    public Boolean getIsSelected() {
        return this.isSelected;
    }

    public void setIsSelected(Boolean isSelected) {
        this.isSelected = isSelected;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1925502270)
    public List<OrderProductDB> getOrderProductDBList() {
        if (orderProductDBList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            OrderProductDBDao    targetDao             = daoSession.getOrderProductDBDao();
            List<OrderProductDB> orderProductDBListNew = targetDao._queryOrderDB_OrderProductDBList(id);
            synchronized (this) {
                if (orderProductDBList == null) {
                    orderProductDBList = orderProductDBListNew;
                }
            }
        }
        return orderProductDBList;
    }

    /**
     * Resets a to-many relationship, making the next get call to query for a fresh result.
     */
    @Generated(hash = 1591415400)
    public synchronized void resetOrderProductDBList() {
        orderProductDBList = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    @Override
    public int getItemType() {
        return this.item_type;
    }

    public int getItem_type() {
        return this.item_type;
    }

    public void setItem_type(int item_type) {
        this.item_type = item_type;
    }

    public int getDiscountPercent() {
        return this.discountPercent;
    }

    public void setDiscountPercent(int discountPercent) {
        this.discountPercent = discountPercent;
    }

    public String getFindZero() {
        return this.findZero;
    }

    public void setFindZero(String findZero) {
        this.findZero = findZero;
    }

    public String getTotalGiftPrice() {
        return this.totalGiftPrice;
    }

    public void setTotalGiftPrice(String totalGiftPrice) {
        this.totalGiftPrice = totalGiftPrice;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1081593541)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getOrderDBDao() : null;
    }
}
